let form = layui.form;
let layer = layui.layer;
$(function () {
  form.verify({
    pwd: [/^[\S]{6,12}$/, "密码必须6到12位，且不能出现空格"],
  });

  //提交密码

  $(".layui-form").on("submit", function (e) {
    e.preventDefault();
    $.ajax({
      method: "POST",
      url: "/my/updatepwd",
      data: $(this).serialize(),
      success: function (res) {
        if (res.status !== 0) {
          return layer.msg("更新密码失败");
        }

        $(".layui-form")[0].reset();
        layer.msg("更新密码成功");
      },
    });
  });
});
